package com.order;




import com.order.config.LoadBalancerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;


import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
// 没有设置 需要进行负载均衡的名字  获取注册中心中所有的服务
//@LoadBalancerClients(defaultConfiguration=LoadBalancerConfig.class)
// 指定prodeuct 实例的时候使用的是随机的算法
@LoadBalancerClient(name = "prodeuct",configuration = LoadBalancerConfig.class)
//@EnableFeignClients
//@LoadBalancerClients(value = {@LoadBalancerClient(name = "prodeuct",configuration = LoadBalancerConfig.class),
//  @LoadBalancerClient(name="",configuration = LoadBalancerConfig.class)
//})
//@LoadBalancerClient(name = "prodeuct",configuration = LoadBalancerConfig.class)
public class OrderApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class);
    }

    //RestTemplate
    // 作为一个bean注入到spring容器里面
    @Bean
    @LoadBalanced //  默认使用的是轮询算法  随机选择
    public RestTemplate getRestTemplate(){
        return  new RestTemplate();
    }


}
